home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18454 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  61 lines

  1. Path: news.th-darmstadt.de!news
  2. From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Correct Ansi C++ behavior?
  5. Date: 20 Apr 1996 14:44:01 +0200
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Sender: enno@kitz.inferenzsysteme.informatik.th-darmstadt.de
  8. Message-ID: <ltbukn83qm.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de>
  9. References: <3177C562.7578@ix.netcom.con>
  10. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  11. In-reply-to: Robert Kleemann's message of Fri, 19 Apr 1996 09:54:58 -0700
  12. X-Newsreader: Gnus v5.1
  13.  
  14. In article <3177C562.7578@ix.netcom.con> Robert Kleemann <goose@ix.netcom.con> writes:
  15.  
  16.    The following code compiles cleanly with MS VC v4.0 but I believe the last 
  17.    line should result in an error.  Does anyone know for certain whether this is 
  18.    a bug or correct C++ behavior?  I don't have any other compilers to test it 
  19.    on.
  20.  
  21.    thanx!
  22.    Robert
  23.  
  24.    class Bar;
  25.  
  26.    class Foo
  27.    {
  28.    public:
  29.        Foo();
  30.        Foo(const Foo& p);
  31.    private:
  32.        // only Bar member functions and friends can
  33.        // create a Foo object from a Bar object
  34.        Foo(const Bar& p);
  35.    };
  36.  
  37.    class Bar
  38.    {
  39.    public:
  40.        Bar();
  41.        Bar(const Bar& p);
  42.        // any function can create a Bar object
  43.        // from a Foo object
  44.        Bar(const Foo& p);
  45.    private:
  46.    };
  47.  
  48.    void main()
  49.    {
  50.        Foo f;
  51.        Bar b;
  52.        Bar b2(f); // legal
  53.        b = Bar(f); // legal
  54.        //Foo f2(b); // should be illegal and is
  55.        f = Foo(b); // I believe this should also be illegal but it isn't
  56.    }
  57.  
  58. The compiler should complain about both lines.
  59.  
  60.         Enno
  61.